package g.beny.manage.services;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.service.EntityService;

import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.log.Log;
import org.nutz.log.Logs;

import g.beny.manage.bean.Accountuser;
import g.beny.manage.bean.Appmenu;

@IocBean(fields={"dao"})
public class AccountuserService extends EntityService<Accountuser>{

    private static final Log log = Logs.get();
	
	public Object list(Cnd cnd){
		List<Accountuser> list = dao().query(Accountuser.class, cnd);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("total", cnd.getPager().getRecordCount());
		map.put("rows", list);
		return map;
	}

	public boolean add(Accountuser obj) throws Throwable{
			dao().insert(Appmenu.class,Chain.from(null));
			dao().insert(obj);
			return true;
	}
	

	public boolean delete(Accountuser obj){
		try{
			dao().delete(obj);
			return true;
		}catch (Throwable e) {
			if (log.isDebugEnabled())
				log.debug("E!!",e);
			return false;
		}
	}

	public boolean update(Accountuser obj){
		try{
			dao().update(obj);
			return true;
		}catch (Throwable e) {
			if (log.isDebugEnabled())
				log.debug("E!!",e);
			return false;
		}
	}
}